import Vue from "vue";
import VueRouter from "vue-router";
import Home from "../views/Home.vue";
import About from "../views/About.vue";

Vue.use(VueRouter);
// 如果这个路由有其他子路由，需要另外注册一个路由，任然使用这个组件即可。
// 本案例就是有子路由，所以需要才后面重新定义main页面的路由
// const routes = [
//   {
//     path: "/main",
//     name: "Main",
//     component: Main,
//     children: [
//       {
//         path: "/home",
//         name: "Home",
//         component: Home,
//       },
//       {
//         path: "/about",
//         name: "About",
//         // route level code-splitting
//         // this generates a separate chunk (about.[hash].js) for this route
//         // which is lazy-loaded when the route is visited.
//         component: () =>
//           import(/* webpackChunkName: "about" */ "../views/About.vue"),
//       },
//     ],
//   },
//   {
//     path: "/main/*",
//     name: "Main",
//     component: Main,
//   },
// ];

const routes = [
  {
    path: "/",
    name: "Home",
    component: Home,
  },
  {
    path: "/vue",
    name: "Home1",
    component: Home,
  },
  {
    path: "/about1",
    name: "About",
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: About,
  },
];

const router = new VueRouter({
  // mode: "hash",
  mode: "history",
  base: "/vue",
  // base: process.env.BASE_URL,
  routes,
});

export default router;
